package com.neusoft.movie.v_movies.fragment;

import android.content.Intent;
import android.graphics.Rect;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.neusoft.movie.v_movies.R;
import com.neusoft.movie.v_movies.activity.SearchMovieActivity;
import com.neusoft.movie.v_movies.adpater.MoviesAdapter;
import com.neusoft.movie.v_movies.adpater.NewsAdapter;
import com.neusoft.movie.v_movies.javabean.MoviesBean;
import com.neusoft.movie.v_movies.javabean.NewsBean;
import com.neusoft.movie.v_movies.listener.RetrofitListener;
import com.neusoft.movie.v_movies.model.MoviesModel;
import com.neusoft.movie.v_movies.model.NewsModel;

import java.util.List;

/**
 * Created by Administrator on 2017/12/25.
 */

public class NewsFragment  extends BaseFragment implements RetrofitListener<List<NewsBean>> {
    RecyclerView recyclerView;


    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,@Nullable Bundle savedInstanceState) {
        setLayout_file(R.layout.mtab02);
        return super.onCreateView(inflater, container, savedInstanceState);
    }

    @Override
    void initEvents() {

    }

    @Override
    void initViews() {
        recyclerView = (RecyclerView)view.findViewById(R.id.news_list);
        recyclerView.setLayoutManager(new LinearLayoutManager(this.getActivity()));
    }

    @Override
    void initData() {
        NewsModel newsModel = new NewsModel();
        newsModel.getNewslist(this);

    }


    @Override
    public void onSuccess(List<NewsBean> newsBeen, int flag) {
        NewsAdapter adapter = new NewsAdapter(getActivity(),newsBeen);
        recyclerView.setAdapter(adapter);
    }

    @Override
    public void onFailed() {

    }

}
